package yartiss.engine.simulation.events;

import java.util.Map;

import yartiss.engine.simulation.Event;
import yartiss.engine.simulation.system.ITask;



public class ActivateTaskEvent extends Event {

	public ActivateTaskEvent(ITask task,int procId, long date, Map<String, Long> metrics, EventGenerator eventGenerator) {
		super(task,procId, date, metrics,  eventGenerator);
	}

	@Override
	public void actionPerformed(long date){
		getTask().activate(date);

		getEventGenerator().generateEvent("activate_task" ,-1, getTask(), getDate() + getTask().getPeriod(), null);
		getEventGenerator().generateEvent("check_deadline",-1, getTask(), getDate() + getTask().getDeadline(), null);
	}
	
	
	@Override
	public String toString(){
		return "activate_task";
	}
	
	@Override
	public void accept(IEventVisitor visitor){
		visitor.visit(this);
	}

}
